package com.datatypes;
import java.io.Serializable;
import java.util.ArrayList;

import android.content.Context;

import com.appengine.utils.SavingAndLoadingCenter;
import com.sporteamws.SharedPref;

public class User implements Serializable{

	// data members

	// user unique facebook id

	private String facebook_id;

	// users facebook code

	private String facebook_code;

	// users device ID code
	private String dev_id;

	// users registration ID code
	private String reg_id;

	// user first name
	private String first_name;

	// user last name
	private String last_name;

	// user age, should be grater then 8
	private int age;

	// user email, as setup in facebook
	private String email;

	// user weight, should be greater then 40
	private double weight;

	// user workout_level (0.8 is the highest(best shape) and 1 is the lowest)
	private double workout_level;

	private String android_state;

	private long last_updated;

	// user gender ("male"/"female"/"unknown")
	private String gender;

	// default constructor
	public User() {
		age = 0;
		facebook_id = null;
		first_name = null;
		last_name = null;
		email = null;
		workout_level = 0.9; // default value
		gender = "unknown"; // default value
		weight = 65; // default value
		this.android_state = "No android use";
		this.last_updated = 0;
	}

	public User(int age, String id, String name, String Lname, String email,
			double wl, String gender, double weight) {
		this.age = age;
		this.facebook_id = id;
		this.first_name = name;
		this.last_name = Lname;
		this.email = email;
		this.workout_level = wl;
		this.gender = gender;
		this.weight = weight;
		this.android_state = "No android use";
		this.last_updated = 0;
	}
	
	public User(AEuser ae_user) {
		
		   // get essential user info from appengine user
		   this.SetFacebookID(ae_user.GetFacebookID());
		   this.setDev_id(ae_user.getDev_id());
		   this.SetEmail(ae_user.GetEmail());
		   this.SetFirstName(ae_user.GetFirstName());
		   this.SetLastName(ae_user.GetLastName());
		   this.SetAge(ae_user.GetAge());
		   this.setReg_id(ae_user.getReg_id());
		   this.SetGender(ae_user.GetGender());
		   this.SetWeight(ae_user.GetWeight());
		   this.SetAge(ae_user.GetAge());
		   this.SetWorkoutLevel(ae_user.GetWorkoutLevel());
		   this.setLast_updated(ae_user.getLast_updated());
		   this.setReg_id(ae_user.getReg_id());
	}
	

	// member functions
	public boolean SignedIn() {
		// tmp
		return false;
	}

	public String GetFirstName() {
		return first_name;
	}

	public String GetLastName() {
		return last_name;
	}

	public int GetAge() {
		return age;
	}

	public double GetWorkoutLevel() {
		return workout_level;
	}

	public String GetEmail() {
		return email;
	}

	public String GetFacebookID() {
		return facebook_id;
	}

	public double GetWeight() {
		return weight;
	}

	public String GetGender() {
		return gender;
	}

	public void SetFirstName(String first_name) {
		this.first_name = first_name;
	}

	public void SetLastName(String last_name) {
		this.last_name = last_name;
	}

	public void SetAge(int age) {
		this.age = age;
	}

	public void SetWeight(double weight) {
		this.weight = weight;
	}

	public void SetEmail(String email) {
		this.email = email;
	}

	public void SetFacebookID(String facebook_id) {
		SharedPref.facebookID = facebook_id; // update user ID in shared pref
		this.facebook_id = facebook_id;
	}

	public void SetWorkoutLevel(double workout_level) {
		this.workout_level = workout_level;
	}

	public void SetGender(String gender) {
		this.gender = gender;
	}

	public String getFacebook_code() {
		return facebook_code;
	}

	public void setFacebook_code(String facebook_code) {
		this.facebook_code = facebook_code;
	}

	public String getDev_id() {
		return dev_id;
	}

	public void setDev_id(String dev_id) {
		this.dev_id = dev_id;
	}

	public String getReg_id() {
		return reg_id;
	}

	public void setReg_id(String reg_id) {
		this.reg_id = reg_id;
	}

	@Override
	public String toString() {
		return "User id: " + this.facebook_id + " User name: "
				+ this.first_name + " " + this.last_name;
	}

	public String getAndroid_state() {
		return android_state;
	}

	public void setAndroid_state(String android_state) {
		this.android_state = android_state;
	}

	public long getLast_updated() {
		return last_updated;
	}

	public void setLast_updated(long last_updated) {
		this.last_updated = last_updated;
	}


}
